home *** CD-ROM | disk | FTP | other *** search
- /*
- File: DrawEditor.h
-
- Contains: Sample part editor class implementation
-
- Written by: Dave Stafford
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- */
-
- #ifndef _DRAWEDITOR_
- #define _DRAWEDITOR_
-
- // -- DrawEditor Includes --
-
- #ifndef _COMPILERDEFS_
- #include "CompDefs.h"
- #endif
-
- #ifndef _DRAWEDITORGLOBALS_
- #include "DrawEditorGlobals.h"
- #endif
-
- // -- OpenDoc Includes --
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef _WINUTILS_
- #include <WinUtils.h>
- #endif
-
- // -- Macintosh Includes --
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- //==============================================================================
- // Forward Declarations
- //==============================================================================
-
- // -- SOM
- class Environment;
-
- // -- OpenDoc
-
- class ODFacet;
- class ODFocusSet;
- class ODFrame;
- class ODMenuBar;
- class ODShape;
- class ODStorageUnit;
- class ODWindow;
- class ODSession;
- class ODDraft;
-
- // -- DrawEditor
-
- class CShape;
- class CSelection;
- class CCommand;
- class CCloneInfo;
- class CFrameList; // Sample Code List Object
- class COrderedList; // SampleCode Utility List Object
- class CPublishLink;
- class CSubscribeLink;
- class CPartContent;
-
- //==============================================================================
- // DrawEditor
- //==============================================================================
- class DrawEditor {
-
- //========================
- public:
-
- DrawEditor();
- ~DrawEditor();
-
- // -- Initialization --
-
- void InitPart(Environment* ev, ODStorageUnit* storageUnit,
- ODPart* partWrapper);
- void InitPartFromStorage(Environment* ev, ODStorageUnit* storageUnit,
- ODPart* partWrapper);
-
- // -- Accessors --
- ODBoolean IsReadOnly();
-
- ODLinkStatus GetLinkStatus() const;
- ODValueType GetEditorKind() const;
- ODSession* GetSession(Environment* ev) const;
- ODDraft* GetDraft(Environment* ev) const;
- ODPart* GetODPart() const;
-
-
- COrderedList* GetShapeList() const;
-
- ODFacet* GetRootFacetOfActiveWindow(Environment* ev) const;
- COrderedList* GetEmbeddedFrames() const;
- ODFrame* GetFirstSourceFrame (Environment* ev);
- COrderedList* GetContentDisplayFrames(Environment* ev) const;
- ODFrame* GetANYFrame(Environment* ev) const;
-
- ODULong GetGroupCount() const;
- ODULong GetNewGroupID();
-
- ODSShort GetDocumentWidth();
- ODSShort GetDocumentHeight();
- void SetDocumentWidth( ODSShort width );
- void SetDocumentHeight( ODSShort height );
-
- // -- Storage --
-
- void SetDirty(Environment* ev);
-
- void Release(Environment* ev);
- void ReleaseAll(Environment* ev);
- ODSize Purge(Environment* ev, ODSize size);
- void Externalize(Environment* ev);
- void ClonePartInfo( Environment* ev,
- ODDraftKey key,
- ODInfoType partInfo,
- ODStorageUnitView* storageUnitView,
- ODFrame* scopeFrame );
-
- void CloneInto(Environment* ev, ODDraftKey key,
- ODStorageUnit* destinationSU,
- ODFrame* scopeFrame);
- void WritePartInfo(Environment* ev, ODInfoType partInfo,
- ODStorageUnitView* storageUnitView);
- ODInfoType ReadPartInfo(Environment* ev, ODFrame* frame,
- ODStorageUnitView* storageUnitView);
-
- void ExternalizeKinds(Environment* ev, ODTypeList* kindset);
- void ChangeKind(Environment* ev, ODType kind);
-
- // -- Promises --
- void FulfillPromise(Environment* ev, ODStorageUnitView* promiseSUView);
-
- // -- Layout --
-
- void DisplayFrameAdded(Environment* ev, ODFrame* frame);
- void DisplayFrameRemoved(Environment* ev, ODFrame* frame);
- void DisplayFrameClosed(Environment* ev, ODFrame* frame);
- void DisplayFrameConnected(Environment* ev, ODFrame* frame);
- void AttachSourceFrame(Environment* ev, ODFrame* frame,
- ODFrame* sourceFrame);
- void ViewTypeChanged(Environment* ev, ODFrame* frame);
- void FrameShapeChanged(Environment* ev, ODFrame* frame);
- ODID Open(Environment* ev, ODFrame* frame);
- ODWindow* AcquireFramesWindow(Environment* ev, ODFrame* frame);
-
- // -- Imaging --
-
- void Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
- void GeometryChanged(Environment* ev, ODFacet* facet,
- ODBoolean clipShapeChanged,
- ODBoolean externalTransformChanged);
- void HighlightChanged(Environment* ev, ODFacet* facet);
- void FacetAdded(Environment* ev, ODFacet* facet);
- void FacetRemoved(Environment* ev, ODFacet* facet);
-
- // -- Activation --
-
- ODBoolean BeginRelinquishFocus(Environment* ev, ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* proposedFrame);
- void CommitRelinquishFocus(Environment* ev, ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* proposedFrame);
- void AbortRelinquishFocus(Environment* ev, ODTypeToken focus,
- ODFrame* ownerFrame,
- ODFrame* proposedFrame);
- void FocusAcquired(Environment* ev,ODTypeToken focus,
- ODFrame* ownerFrame);
- void FocusLost(Environment* ev,ODTypeToken focus,
- ODFrame* ownerFrame);
-
- void RelinquishAllFoci(Environment* ev, ODFrame* frame);
-
- void PartActivated( Environment* ev, ODFrame* frame );
-
- // -- Event Handling --
-
- ODBoolean HandleEvent(Environment* ev, ODEventData* event,
- ODFrame* frame, ODFacet* facet,
- ODEventInfo* eventInfo);
- void AdjustMenus(Environment* ev, ODFrame* frame);
-
-
- // -- Drag & Drop --
- void DropCompleted(Environment *ev, ODPart* part, ODDropResult result);
- ODDragResult DragEnter(Environment *ev,
- ODDragItemIterator* dragInfo,
- ODFacet* facet,
- ODPoint* where);
- ODDragResult DragWithin(Environment *ev,
- ODDragItemIterator* dragInfo,
- ODFacet* facet,
- ODPoint* where);
- void DragLeave(Environment *ev,
- ODFacet* facet,
- ODPoint* where);
- ODDropResult Drop(Environment *ev,
- ODDragItemIterator* dragInfo,
- ODFacet* facet,
- ODPoint* where);
-
-
- // -- Commands --
- void ExecuteCommand(Environment *ev, CCommand* command);
- void UndoAction(Environment *ev, ODActionData* actionState);
- void RedoAction(Environment *ev, ODActionData* actionState);
- void DisposeActionState(Environment *ev,
- ODActionData* actionState,
- ODDoneState doneState);
- // Embedding
- ODShape* AdjustBorderShape(Environment *ev,
- ODFacet *embeddedFacet, ODShape* borderShape);
- void InvalidateActiveBorder(Environment *ev, ODFrame *frame);
-
- void ClipEmbeddedFacets(Environment *ev, ODFrame* containingFrame);
- void ClipEmbeddedFacets(Environment *ev, ODFacet *containingFacet);
- void RemoveEmbeddedFrame(Environment *ev, ODFrame* embeddedFrame);
- ODShape* RequestFrameShape(Environment *ev, ODFrame* embeddedFrame,
- ODShape* frameShape);
- ODFrame* RequestEmbeddedFrame(Environment* ev,
- ODFrame* containingFrame,
- ODFrame* baseFrame,
- ODShape* frameShape,
- ODPart* embedPart,
- ODTypeToken viewType,
- ODTypeToken presentation,
- ODBoolean isOverlaid);
- void UsedShapeChanged(Environment* ev, ODFrame* embeddedFrame);
-
- CShape* ShapeForFrame(Environment* ev, ODFrame* embeddedFrame);
-
- // Linking OpenDoc API
- void EmbeddedFrameUpdated(Environment* ev, ODFrame* frame, ODUpdateID updateID);
- ODLinkSource* CreateLink(Environment *ev, ODByteArray* data);
-
- // Linking Internal support
- void SetPendingPublish(CPublishLink *link);
- void SetPendingDragPublish(CPublishLink *link);
- void DeletePendingPublish(Environment* ev);
- void AddPublishLink(CPublishLink *link);
- void RemovePublishLink(Environment* ev, CPublishLink *link);
-
- //========================
- protected:
-
- // -- Initialization --
-
- void Initialize(Environment* ev);
- void LoadMenus(Environment* ev);
-
- // -- Storage --
-
- void CheckAndAddProperties(Environment* ev,
- ODStorageUnit* storageUnit);
- void CleanseContentProperty(Environment* ev,
- ODStorageUnit* storageUnit);
- void InternalizeStateInfo(Environment* ev,
- ODStorageUnit* storageUnit);
- void InternalizeContent(Environment* ev,
- ODStorageUnit* storageUnit);
- void ExternalizeStateInfo( Environment* ev,
- ODStorageUnit* storageUnit,
- CCloneInfo* info);
- void ExternalizeContent( Environment* ev,
- ODStorageUnit* storageUnit,
- CCloneInfo* cloneInfo );
-
- // -- Event Handling --
-
- ODBoolean HandleMenuEvent(Environment* ev, ODEventData* event,
- ODFrame* frame);
- ODBoolean HandleMouseEvent(Environment* ev, ODEventData* event,
- ODFacet* facet, ODEventInfo* eventInfo);
- ODBoolean HandleWindowEvent(Environment* ev, ODEventData* event,
- ODFrame* frame);
- void HandleMouseDown( Environment* ev,
- ODFacet* facet,
- ODEventData* event,
- ODEventInfo* eventInfo );
-
- ODBoolean HandleSelection( Environment* ev,
- ODFacet* facet,
- ODEventData* event,
- ODEventInfo* eventInfo );
-
- ODBoolean HandleMouseDownInEmbeddedFrame( Environment* ev,
- ODFacet* facet,
- ODEventData* event,
- ODEventInfo* eventInfo );
-
- ODBoolean HandleMouseDownInEmbeddedFrameBorder( Environment* ev,
- ODFacet* facet,
- ODEventData* event,
- ODEventInfo* eventInfo );
-
- ODBoolean HandleMouseUpActivate( Environment* ev, ODFacet* facet);
-
-
- // -- Dialogs --
- ODBoolean PrepareForDialog( Environment* ev, ODFrame* frame );
- void DoneWithDialog( Environment* ev, ODFrame* frame );
- void DoDialogBox(Environment* ev, ODFrame* frame,
- ODSShort dialogID, ODUShort errorNumber = 0);
-
- // -- Imaging --
-
- void DrawIconView(Environment* ev, ODFacet* facet);
- void DrawThumbnailView(Environment* ev, ODFacet* facet);
- void GenerateThumbnail( Environment* ev, ODFrame* frame );
- void DrawFrameView(Environment* ev, ODFacet* facet, ODShape* invalidShape);
- void DrawGrid(Environment* ev, ODFrame* frame);
-
- // -- Activation --
-
- ODBoolean ActivateFrame(Environment* ev, ODFrame* frame);
- void WindowActivating(Environment* ev, ODFrame* frame,
- ODBoolean activating);
-
- // -- Layout --
-
- ODWindow* CreateWindow(Environment* ev, ODFrame* frame, ODType frameType,
- WindowProperties* windowProperties);
- void CleanupWindow(Environment* ev, ODFrame* frame);
- WindowProperties* GetDefaultWindowProperties( Environment* ev,
- ODFrame* sourceFrame,
- Rect* windowRect );
- WindowProperties* GetSavedWindowProperties(Environment* ev, ODFrame* frame);
- Rect CalcPartWindowSize(Environment* ev, ODFrame* sourceFrame);
- Rect CalcPartWindowPosition(Environment* ev, ODFrame* frame,
- Rect* partWindowBounds);
- ODFacet* GetActiveFacetForFrame(Environment* ev, ODFrame* frame);
- ODShape* CalcNewUsedShape(Environment* ev, ODFrame* frame);
- void UpdateFrame(Environment* ev, ODFrame* frame, ODTypeToken view,
- ODShape* usedShape);
- void CleanupDisplayFrame(Environment* ev, ODFrame* frame,
- ODBoolean frameRemoved);
-
- // -- Clipboard --
- ODBoolean DoCutCopy(Environment* ev, ODCommandID commandID, ODFrame* frame);
- ODBoolean DoPaste(Environment* ev, ODFrame* frame);
- ODBoolean DoPasteAs(Environment* ev, ODFrame* frame, ODFacet* facet);
- ODBoolean DoClear(Environment* ev, ODFrame* frame);
- public:
-
- // -- Content --
- CShape* CreateShape(Environment* ev,
- ODSShort shapeType,
- Rect shapeBounds = gGlobals->fZeroRect);
-
- void AddShape(Environment* ev, CShape* shape);
- void RemoveShape(Environment* ev, CShape* shape);
- CShape* WhichShape(Environment *ev, Point& where);
- void InvalidateShape(Environment* ev, CShape* shape);
-
- void MoveShapeBefore(Environment* ev, CShape* moveShape, CShape* before);
- void MoveShapeAfter(Environment* ev, CShape* moveSshape, CShape* after);
-
- void DoOpen(Environment* ev, ODFrame* frame);
-
- void AddSubscribeLink(CSubscribeLink* link);
-
- void RemoveSubscribeLink(CSubscribeLink* link);
-
- COrderedList* GetSubscribeLinks();
-
- COrderedList* GetPublishLinks();
- void ContentUpdated(Environment* ev, ODUpdateID id);
-
- void LinkUpdated(Environment* ev, ODLink* odLink, ODUpdateID updateID);
- CSelection* GetSelection();
-
- CPublishLink* GetPendingPublish();
- void EditInLink(Environment* ev, CSubscribeLink* link);
-
- void LinkStatusChanged(Environment* ev, ODFrame* frame);
- void ShowCantEditDialog(Environment* ev);
-
- ODBoolean EditInLinkAttempted(Environment* ev, ODFrame* frame);
-
- void RevealLink(Environment* ev, ODLinkSource* linkSource);
- CPublishLink* GetPendingDragPublish();
-
-
-
-
-
-
-
- //========================
- private:
-
- // Since we are lazily internalizing display frames,
- // this is actually a list of CDisplayFrameProxy
- // objects, rather than ODFrames.
- COrderedList* fDisplayFrameProxies;
-
- ODBoolean fDirty;
- ODPart* fSelf;
- ODBoolean fReadOnlyStorage;
- ODLinkStatus fLinkStatus;
-
-
- // Content data
- ODULong fGroupCount;
- CSelection* fSelection;
- COrderedList* fShapeList;
-
- ODFacet* fHilightedDragFacet;
- ODShape* fActiveBorderShape;
-
- COrderedList* fEmbeddedFrames;
-
- CPublishLink* fPendingPublish;
- CPublishLink* fPendingDragPublish;
-
- // Ref to lists in fPartContent retained for convenience
- COrderedList* fPublishLinks;
- COrderedList* fSubscribeLinks;
-
- CPartContent* fPartContent;
-
-
- };
-
-
- #endif